package cn.catfish.service.impl;

import cn.catfish.entity.BorrowRecord;
import cn.catfish.mapper.RecordMapper;
import cn.catfish.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecordServiceImpl implements RecordService {
@Autowired
    private RecordMapper recordMapper;

    @Override
    public BorrowRecord getRecordById(int id) {
        return recordMapper.getRecordById(id);
    }

    @Override
    public List<BorrowRecord> getRecordsByUserId(int userId) {
        return recordMapper.getRecordsByUserId(userId);
    }

    @Override
    public List<BorrowRecord> getRecordsByBookId(int bookId) {
        return recordMapper.getRecordsByBookId(bookId);
    }

    @Override
    public List<BorrowRecord> getRecords(int userId, int bookId) {
        return recordMapper.getRecordByUserAndBook(userId, bookId);
    }

    @Override
    public void addRecord(BorrowRecord borrowRecord) {
        recordMapper.insertRecord(borrowRecord);
    }

    @Override
    public int deleteRecord(int id) {
        return recordMapper.deleteRecord(id);
    }
}
